home *** CD-ROM | disk | FTP | other *** search
- program rotatevild;
- {
- VILD ROTERING #1
- - af Bjarke Viksφe
- feb 1994
-
- THIS PROGRAM WAS CODED BY BJARKE VIKS0E.
- YOU ARE FREE TO DO WHATEVER YOU WANT WITH THIS PIECE OF CODE.
- E-MAIL ME AT: dat92230@rix02.lyngbyes.dk IN 1994 FOR CHAT AND CODE.
-
- Pretty basic. Can do the stuff Future Crew did. Seems a bit jerky when
- zooming at close range - maybe because of decimal lost in some
- calc'ing.
- Hit ESCAPE to exit...
- }
-
- {$IFDEF DPMI}
- Virker nu kun i real-mode pga. selvmodificerende kode!
- Skift til REAL-MODE!!!!!
- {$ENDIF}
-
- (*{$DEFINE DEBUG}*)
-
- uses
- DEMOINIT, ILBM256;
-
- const
- MAXY = 400;
-
- var
- i : integer;
- picture : pScreen;
- tabel : array[0..320] of integer;
- xpostabel : array[1..160] of integer;
- relYtabel : array[-MAXY..MAXY] of integer;
- sinustabel : array[0..639] of integer;
- yoff : integer;
- v : word;
- vinkel1, vinkel2 : integer;
- zpos : word;
- z : longint;
- inserted : boolean;
-
- const
- display1 : word = $0000;
- display2 : word = $4000;
- display3 : word = $8000;
-
-
-
- (*------------------------------------------------*)
-
- procedure SwapDisplay;
- var
- temp : word;
- begin
- temp:=display1;
- display1:=display2;
- display2:=display3;
- display3:=temp;
- SetAddress(ptr((SEGA000),display3));
- end;
-
-
- (*------------------------------------------------*)
-
- procedure SetupSinus;
- var
- i : integer;
- v, vadd : real;
- begin
- v:=0.0;
- vadd:=(2.0*pi/512.0);
- for i:=0 to 639 do begin
- sinustabel[i]:=round(sin(v)*32767);
- v:=v+vadd;
- end;
- end;
-
- procedure InitDemo;
- var
- i : integer;
- begin
- ClearWholeScreen;
- SetupSinus;
-
- New(picture);
- LoadPix(picture, 'parasit1.lbm');
- SetCMAP;
-
- v:=0;
- zpos:=0;
- for i:=-MAXY to MAXY do relYtabel[i]:=i*320;
- end;
-
- procedure UninitDemo;
- begin
- Dispose(picture);
- end;
-
-
- (*------------------------------------------------*)
-
- procedure MakeXtabel; assembler;
- asm
- mov ax,ds
- mov es,ax
- lea di,xpostabel
- lea si,tabel+2
- mov cx,160
- cld
- @makex1:
- lodsw
- mov bx,ax
- sal bx,1
- mov ax,[OFFSET relYtabel+(MAXY*2)+bx]
- stosw
- add si,2
- loop @makex1
-
- mov ax,ds
- mov es,ax
- lea si,tabel
- lea di,xpostabel
- mov dx,4
- mov bx,2
- mov cx,160
- cld
- @makex:
- mov ax,[si]
- add [di],ax
- add si,dx
- add di,bx
- loop @makex
- end;
-
-
- procedure CalcVinkel;
- begin
- vinkel1:=sinustabel[v AND 511];
- vinkel2:=sinustabel[(v AND 511)+128];
- inc(v,1);
-
- z:=longdiv(sinustabel[zpos AND 511],50)+800;
- inc(zpos,5);
- end;
-
-
- procedure RotateCoord(x,y : integer; VAR rx,ry : integer);
- var
- cx,cy : longint;
- begin
- cx := (longmul(x,vinkel2) - longmul(y,vinkel1)) DIV 128;
- cy := (longmul(x,vinkel1) + longmul(y,vinkel2)) DIV 128;
- rx := cx DIV z;
- ry := cy DIV z;
- end;
-
- (*------------------------------------------------*)
-
- procedure CalcSlope(x1,y1,x2,y2, n : integer);
- var
- x,y,delx,dely : longint;
- begin
- delx := (x2-x1) * ($10000 DIV (n-1));
- dely := (y2-y1) * ($10000 DIV (n-1));
-
- asm
- xor dx,dx
- mov ax,x1
- mov WORD PTR x,dx
- mov WORD PTR x+2,ax
- mov ax,y1
- mov WORD PTR y,dx
- mov WORD PTR y+2,ax
-
- mov ax,ds
- mov es,ax
- lea di,tabel
- mov si,n
- mov ax,WORD PTR x+2
- mov dx,WORD PTR x
- mov bx,WORD PTR y+2
- mov cx,WORD PTR y
- @loop1:
- add dx,WORD PTR delx
- adc ax,WORD PTR delx+2
- stosw
- add cx,WORD PTR dely
- adc bx,WORD PTR dely+2
- mov [di],bx
- add di,2
- dec si
- jnz @loop1
- end;
- end;
-
-
- procedure BigScreenRotator(x,y : integer);
- var
- XYoffset : integer;
- screenoffset : integer;
- begin
- screenoffset := display1+yoff;
-
- asm
- mov ax,y
- mov dx,320
- imul dx
- add ax,x
- mov XYoffset,ax
-
-
- {modify code}
- cmp inserted,TRUE
- je @noinsert
- mov inserted,TRUE
-
- mov bx,4
- lea si,xpostabel
- lea di,@megaloop1+2
- mov cx,40
- @insert1:
- mov ax,[si]
- mov [cs:di],ax
- add si,bx
- add di,bx
- mov ax,[si]
- mov [cs:di],ax
- add si,bx
- add di,5
- loop @insert1
-
- lea si,xpostabel+2
- lea di,@megaloop2+2
- mov cx,40
- @insert2:
- mov ax,[si]
- mov [cs:di],ax
- add si,bx
- add di,bx
- mov ax,[si]
- mov [cs:di],ax
- add si,bx
- add di,5
- loop @insert2
- @noinsert:
-
-
- {set bitplane}
- mov dx,$3C4
- mov ax,$0302
- out dx,ax
-
- push ds
- {set pixels 0,1,4,5,8,9 ... for line}
- mov es,SEGA000
- mov di,screenoffset
- lds si,picture
- add si,XYoffset
- mov bx,WIDTH
- cld
- @megaloop1:
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
-
- {set bitplane}
- mov dx,$3C4
- mov ax,$0C02
- out dx,ax
- {set pixels 2,3,6,7,10,11 ... for line}
- mov di,screenoffset
- @megaloop2:
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
- mov al,[si+3000]
- mov ah,[si+3000]
- stosw
-
- pop ds
- end;
- end;
-
-
- procedure RotateScreen;
- var
- x, y : integer;
- i : integer;
- begin
- yoff:=0;
- inserted:=FALSE;
- i:=0;
- while (i<200) do begin
- x:=tabel[i]; y:=tabel[i+1];
- BigScreenRotator(x,y);
- inc(i,2);
- inc(yoff,WIDTH);
- end;
- end;
-
-
- (*------------------------------------------------*)
-
- procedure RunOnce;
- var
- x1,y1, x2,y2 : integer;
- begin
- SwapDisplay;
- while retraces=0 do ;
- retraces:=0;
- {$IFDEF DEBUG}
- setRGB(0,63,0,0);
- {$ENDIF}
- CalcVinkel;
-
- RotateCoord(-200,0,x1,y1);
- RotateCoord(200,0,x2,y2);
- CalcSlope(x1,y1,x2,y2,160);
- MakeXtabel;
-
- RotateCoord(0,-180,x1,y1);
- RotateCoord(0,180,x2,y2);
- inc(x1,160); inc(x2,160);
- inc(y1,100); inc(y2,100);
- CalcSlope(x1,y1,x2,y2,100);
- RotateScreen;
- {$IFDEF DEBUG}
- setRGB(0,0,0,0);
- {$ENDIF}
- end;
-
-
- begin
- OpenScreen;
- SetLineRepeat(3);
- InitDemo;
- SetAllInterrupts;
- while not (Key='e') do RunOnce;
- RestoreAllInterrupts;
- CloseScreen;
- UninitDemo;
- end.
-